<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
        <!-- 
            自定义属性以data-属性名
            访问的时候obj.dataset.属性名
        -->
      <div id = "box" class="box" p-abc="p01" data-id="1" data-name="zhangsan"></div>

      <script>
            var boxObject = document.querySelector("#box");
            //被封装到了dataset属性中
            console.log(boxObject.dataset.id);
            console.log(boxObject.dataset.name);
            console.log(boxObject.dataset)
            console.log(boxObject["data-id"]);

            console.log(boxObject["data-name"]);
            console.log(boxObject.id)
            console.log(boxObject["p-id"]);
            //随便乱写的属性=>
            console.dir(boxObject.getAttribute("p-abc"))
      </script>
</body>
</html>